home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d13
/
route.arc
/
ALLOC.C
next >
Wrap
C/C++ Source or Header
|
1989-11-24
|
867b
|
40 lines
#include <stdio.h>
#ifndef M_XENIX
#include <stdlib.h>
#include <dos.h>
#else
#include <malloc.h>
#endif
char far *Alloc( long );
void Nomem( void );
char far *Alloc ( x ) /* allocate x bytes of far memory */
long x;
{
#ifndef M_XENIX
union REGS regs;
regs.h.ah = 0x48; /* allocate memory dos call */
x = (x+15)>>4; /* get number of paragraphs to allocate */
regs.x.bx = (int)x;
intdos( ®s, ®s ); /* call dos; request memory */
if (regs.x.cflag) /* memory allocation error */
Nomem();
return( (char far *)((long)regs.x.ax<<16) ); /* make a far pointer */
#else
char far *fp;
if ((fp = malloc((unsigned int)x)) == (char far *)NULL)
Nomem(); /* memory allocation error */
return(fp);
#endif
}
void Nomem () { /* a memory allocation request has failed */
printf( "out of memory\n" );
exit( -1 );
}